﻿/**
 * @file service_data_pool_op.hpp
 * @date 2021/04/13 20:34
 *
 * @author harrybao (harrybao@123u.com)
 *
 * @brief 服务数据池操作
 *
 * @version v1.0.0
 *
 * @copyright Copyright © 2021 All Rights Reserved 上海欢乐互娱网络科技有限公司
 *
 * @par history:
 * <table>
 * <tr><th>Date                     <th>Version     <th>Author <th>Description
 * <tr><td>2021/04/13 20:34         <td>1.0.0       <td>harrybao
 * <td>创建初始版本
 * </table>
 */

// #ifndef SERVICE_DATA_POOL_OP_H
// #define SERVICE_DATA_POOL_OP_H

#pragma once

#include "service_data_pool.hpp"
#include "singleton.hpp"

namespace guild_service {
namespace detail {

template <typename T>
// inline static
void pool_resize(std::size_t count) {
  common::singleton<service_data_pool<T>>::instance()->resize(count);
}

template <typename T>
// inline static
std::size_t pool_size() {
  return common::singleton<service_data_pool<T>>::instance()->size();
}

template <typename T>
// inline static
void pool_add_data(const T &data) {
  common::singleton<service_data_pool<T>>::instance()->push(data);
}

template <typename T>
// inline static
void pool_add_data(T &&data) {
  common::singleton<service_data_pool<T>>::instance()->push(
      std::forward<T>(data));
}

template <typename T>
// inline static
void pool_set_data(std::size_t index, const T &data) {
  common::singleton<service_data_pool<T>>::instance()->set(index, data);
}

template <typename T>
// inline static
T &pool_get_data(std::size_t index) {
  return common::singleton<service_data_pool<T>>::instance()->get(index);
}

}  // namespace detail
}  // namespace guild_service

// #endif // SERVICE_DATA_POOL_OP_H